var nodemailer = require("nodemailer");
var serverInfo = {
	163: {
		host: "smtp.163.com",
		port: 25,
		secureConnection: true,
	},
	126: {
		host: "smtp.126.com",
		port: 25,
		secureConnection: true,
	}
}
module.exports = function(sender_info, cb) {
	sender_info.from = {
		name: "点纳微站",
		address: "dotnar@126.com"
	};
	sender_info.pass = "dianna123456";
	var serverName = ((sender_info.from.address || sender_info.from).match(/\@([\w\W]+?)\./)[1] || "").toLowerCase();
	var transporterOption = {
		auth: {
			user: (sender_info.from.address || sender_info.from),
			pass: sender_info.pass
		}
	}
	if (serverInfo.hasOwnProperty(serverName)) {
		var serverOption = serverInfo[serverName];
		for (var key in serverOption) {
			serverOption.hasOwnProperty(key) && (transporterOption[key] = serverOption[key]);
		}
	} else {
		transporterOption.service = serverName;
	}
	var transporter = nodemailer.createTransport(transporterOption);
	transporter.sendMail({
		from: sender_info.from,
		to: sender_info.to,
		subject: sender_info.title,
		html: sender_info.content,
		attachments: sender_info.files,
		alternatives: sender_info.alternatives
	}, cb)
}